#version 130

attribute vec3 vertex;
attribute vec3 normal;
attribute vec3 tangent;
attribute vec3 color;
attribute vec2 UV;

uniform mat4 ModelMatrix;
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 ModelViewMatrix;
uniform mat4 ViewProjectionMatrix;
uniform mat4 ModelViewProjectionMatrix;
uniform mat3 NormalMatrix;
uniform mat4 ProjectorMatrix;

varying vec3 outNormal;
varying vec3 outTangent;
varying vec3 outColor;
varying vec2 outUV;
varying vec3 position;
varying vec3 outPosition;

varying vec4 ShadowCoord;

void main() {
	vec3 normalized = normalize(normal);

	ShadowCoord = ProjectorMatrix * ModelMatrix * vec4(vertex + normalized * 0.05,1.0); // + nomal para evitar acné
	
	outPosition = vec3(ModelMatrix * vec4(vertex,1.0));
	position = vec3(ViewMatrix * ModelMatrix * vec4(vertex,1.0));
	outNormal = NormalMatrix * normal;
	outTangent = NormalMatrix * outTangent;
	outColor = color;
	outUV = UV;
	
	gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(vertex,1.0);
}
